package jp.sourceforge.akjrcp.ui;

import org.eclipse.jface.viewers.CellEditor.LayoutData;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Scale;

/**
 * @deprecated use lib swt
 * @author aki
 *
 */
public class LabelScale extends Composite{
private String headerText="";
private String footerText="";
private Label label;
private Scale scale;
	public String getFooterText() {
	return footerText;
}

public void setFooterText(String footerText) {
	this.footerText = footerText;
	updateLabel();
}

public String getHeaderText() {
	return headerText;
}

public void setHeaderText(String headerText) {
	this.headerText = headerText;
	updateLabel();
}

public Scale getScale() {
	return scale;
}

public void setScale(Scale scale) {
	this.scale = scale;
}

public void setLayoutData(GridData labelData,GridData scaleData){
	label.setLayoutData(labelData);
	scale.setLayoutData(scaleData);
}

public void setLayoutData(GridData base,GridData labelData,GridData scaleData){
	this.setLayoutData(base);
	label.setLayoutData(labelData);
	scale.setLayoutData(scaleData);
}

	public LabelScale(Composite parent, int style,int min,int selection,int max) {
		super(parent, style);
		this.setLayout(new GridLayout(2,false));
		label=new Label(this,SWT.NULL);
		scale=new Scale(this,SWT.NULL);
		scale.setMinimum(min);
		
		scale.setMaximum(max);
		scale.setSelection(selection);
		scale.addSelectionListener(new SelectionListener(){

			public void widgetDefaultSelected(SelectionEvent e) {
				
			}

			public void widgetSelected(SelectionEvent e) {
				label.setText(toLabel());
			}});
		
		updateLabel();
	}
	public void updateLabel(){
		label.setText(toLabel());
	}
	//can overwrite
	public String toLabel(){
		return headerText+scale.getSelection()+footerText;
	}
}
